import { Vec2 } from 'cc';
import { Vec3 } from 'cc';
import { Quat } from 'cc';
import { _decorator, Camera, CameraComponent, Component, Mat4, Node, view, View, screen, Size } from 'cc';
import { App } from '../../App';
const { ccclass, property } = _decorator;

/**
 * 3d相机适配, 让不同手机分辨率下看到的桌子模型宽度一致
 */
@ccclass('Screen3dAdapter')
export class Screen3dAdapter extends Component {

    start() {
        
        const camera3d : Camera = this.node.getComponent(Camera);

        const designResolution = view.getDesignResolutionSize();
        const designOrthoHeight = camera3d.orthoHeight;
        const designAspectRatio = designResolution.height / designResolution.width;
        const winAspectRatio = screen.windowSize.height / screen.windowSize.width;

        let finalOrthoHeight = designOrthoHeight / designAspectRatio * winAspectRatio;
        camera3d.orthoHeight = finalOrthoHeight;

        // 这种情况是手机高度很小的时候(特殊处理)
        if (winAspectRatio<=1.7) {
            camera3d.orthoHeight = designOrthoHeight-20
            App.Model.gameManage.BALL_DIA_2D = 50 * 0.85
            if (winAspectRatio<=1.5) {
                camera3d.orthoHeight = designOrthoHeight-50
                App.Model.gameManage.BALL_DIA_2D = 50 * 0.65
            }
        }
        
    }

    update(deltaTime: number) {
        
    }
}


